package service.impl;

import mapper.App_versionMapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import pojo.App_version;
import service.App_versionService;

import javax.annotation.Resource;
import java.util.List;

@Transactional(rollbackFor = {Exception.class})
@Service
public class App_versionServiceImpl implements App_versionService {
    @Resource
    private App_versionMapper appVersionMapper;
    @Override
    public List<App_version> selectByAppId(Integer appId) {
        return appVersionMapper.selectByAppId(appId);
    }

    @Override
    public int addVersion(App_version appVersion) {
        int result=0;
        try {
//            if (appVersionMapper.addVersion(appVersion)>0){
//                result=1;
//            }
            result=appVersionMapper.addVersion(appVersion);
        } catch (Exception e) {
            e.printStackTrace();
            throw e;
        }
        return result;
    }

    @Override
    public App_version selectById(Integer id) {
        return appVersionMapper.selectById(id);
    }

    @Override
    public int del(Integer id) {
        return appVersionMapper.del(id);
    }

    @Override
    public App_version getNewById(Integer id) {
        return appVersionMapper.getNewById(id);
    }

    @Override
    public int updateVersion(App_version appVersion) {
        int result=0;
        try {
            if (appVersionMapper.updateVersion(appVersion)>0){
                result=1;
            }
        } catch (Exception e) {
            e.printStackTrace();
            throw e;
        }
        return result;
    }


}
